import com.sun.deploy.util.VersionString;

import java.util.ArrayList;
import java.util.Collection;
import java.util.HashMap;
import java.util.Map;

public class Games {
    private Collection<String> games = new ArrayList<String>();
    private Map<String, Collection<String>> teamToGames = new HashMap<String, Collection<String>>();

    public void addGame(String winner, String loser, boolean wasTie) {
        String gameStr;
        if (wasTie){
            gameStr = winner+", "+loser+", TIE";
        }
        else{
            gameStr = winner+", "+loser;
        }
        if (wasTie){
            games.add(gameStr);
        }
        else{
            games.add(gameStr);
        }
        if (teamToGames.containsKey(winner)){
            teamToGames.get(winner).add(gameStr);
        }
        else {
            Collection<String> gameList = new ArrayList<String>();
            gameList.add(gameStr);
            teamToGames.put(winner, gameList);
        }
        if (teamToGames.containsKey(loser)){
            teamToGames.get(loser).add(gameStr);
        }
        else {
            Collection<String> gameList = new ArrayList<String>();
            gameList.add(gameStr);
            teamToGames.put(loser, gameList);
        }
    }

    public Collection<String> getAllGames() {
        return games;
    }

    public Collection<String> getGames(String teamName) {
         return teamToGames.get(teamName);
    }
}
